package com.ruoyi.zk.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zk.domain.ZkCollegeline;
import com.ruoyi.zk.service.IZkCollegelineService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 院校录取分数线Controller
 * 
 * @author ruoyi
 * @date 2024-06-18
 */
@Controller
@RequestMapping("/zk/collegeline")
public class ZkCollegelineController extends BaseController
{
    private String prefix = "zk/collegeline";

    @Autowired
    private IZkCollegelineService zkCollegelineService;

    @RequiresPermissions("zk:collegeline:view")
    @GetMapping()
    public String collegeline()
    {
        return prefix + "/collegeline";
    }

    /**
     * 查询院校录取分数线列表
     */
    @RequiresPermissions("zk:collegeline:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZkCollegeline zkCollegeline)
    {
        startPage();
        List<ZkCollegeline> list = zkCollegelineService.selectZkCollegelineList(zkCollegeline);
        return getDataTable(list);
    }

    /**
     * 导出院校录取分数线列表
     */
    @RequiresPermissions("zk:collegeline:export")
    @Log(title = "院校录取分数线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZkCollegeline zkCollegeline)
    {
        List<ZkCollegeline> list = zkCollegelineService.selectZkCollegelineList(zkCollegeline);
        ExcelUtil<ZkCollegeline> util = new ExcelUtil<ZkCollegeline>(ZkCollegeline.class);
        return util.exportExcel(list, "院校录取分数线数据");
    }

    /**
     * 新增院校录取分数线
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存院校录取分数线
     */
    @RequiresPermissions("zk:collegeline:add")
    @Log(title = "院校录取分数线", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZkCollegeline zkCollegeline)
    {
        return toAjax(zkCollegelineService.insertZkCollegeline(zkCollegeline));
    }

    /**
     * 修改院校录取分数线
     */
    @RequiresPermissions("zk:collegeline:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZkCollegeline zkCollegeline = zkCollegelineService.selectZkCollegelineById(id);
        mmap.put("zkCollegeline", zkCollegeline);
        return prefix + "/edit";
    }

    /**
     * 修改保存院校录取分数线
     */
    @RequiresPermissions("zk:collegeline:edit")
    @Log(title = "院校录取分数线", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZkCollegeline zkCollegeline)
    {
        return toAjax(zkCollegelineService.updateZkCollegeline(zkCollegeline));
    }

    /**
     * 删除院校录取分数线
     */
    @RequiresPermissions("zk:collegeline:remove")
    @Log(title = "院校录取分数线", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zkCollegelineService.deleteZkCollegelineByIds(ids));
    }
}
